package com.example.three;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;

public class MyReceiver extends BroadcastReceiver {
    private Message message;

    @Override
    public void onReceive(Context context, Intent intent) {
        //接收MainActivity传过来的数据
        Toast.makeText(context, intent.getStringExtra("cnt"), Toast.LENGTH_SHORT).show();

        //调用Message接口的方法
        message.getMsg(" world");
    }

    interface Message {
        void onCreate(Bundle savedInstanceState);

        public void getMsg(String str);
    }

    public void setMessage(Message message) {
        this.message = message;
    }
}